package person.learn.controller;

import com.alibaba.fastjson.JSONObject;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by barton on 16-1-27.
 * 1.使用@RestController注解，请尽量遵循RESTFUL 接口设计规范
 */
@RestController
@RequestMapping("/interceptor")
public class InterceptorController {

    /**
     * 请求此方法时，会被URLInterceptor方法拦截，等拦截器preHandle()方法处理完成后，才会执行此方法
     *
     * @return
     */
    @RequestMapping(value = "/beilanjie", method = RequestMethod.GET)
    public ResponseEntity<JSONObject> beilanjie() {
        JSONObject json = new JSONObject();
        json.put("result", "此URL被拦截");

        return new ResponseEntity<>(json, HttpStatus.OK);
    }

    @RequestMapping(value = "/bubeilanjie", method = RequestMethod.GET)
    public ResponseEntity<JSONObject> bubeilanjie() {
        JSONObject json = new JSONObject();
        json.put("result", "此URL不被拦截");

        return new ResponseEntity<>(json, HttpStatus.OK);
    }

}
